package com.ruoyi.radar.common;


import org.springframework.context.annotation.Configuration;

import java.util.Date;
import java.util.Map;
import java.util.UUID;

@Configuration
public class CommonUtil {


    //获取uuid
    public String uuId() {
        String sheetId = UUID.randomUUID().toString().replaceAll("-", "");
        return sheetId;
    }

    public Date currentTime() {
        // 获取系统时间
//        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
//        DateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
        Date date = new Date();
        return date;
    }

    public String checkNull(Object obj) {
        String str = (obj == null)?"":obj.toString();
        return str;
    }

    public Map<String, Object> toPage(Map<String, Object> param){
        Integer page = Integer.parseInt((param.get("pageNum") == null || param.get("pageNum") == "")?"1":param.get("pageNum").toString());
        Integer limit = Integer.parseInt((param.get("pageSize") == null || param.get("pageSize") == "")?"10":param.get("pageSize").toString());
        param.put("pageNum",(page-1)*limit);
        param.put("pageSize",limit);
        return param;
    }
}
